Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user to specify alternate wallet and config filenames as arguments #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ptsand
Copy link

@ptsand ptsand commented Jan 17, 2018

Issue #43

@jgoggan
Copy link

jgoggan commented Jan 17, 2018

Awesome! I look forward to this being merged into the main!

@rpesche
Copy link

rpesche commented Feb 18, 2018

You can simplify your function like this:

# Allow user to specify wallet and config filenames as arguments
def handleargs():
    global DATAFILE, CONFFILE
    parser = argparse.ArgumentParser()
    parser.add_argument("-w", "--wallet", type=str, help="Specify wallet filename")
    parser.add_argument("-c", "--config", type=str, help="Specify config filename")
    args = parser.parse_args()
    
    DATAFILE = os.path.join(BASEDIR, args.wallet or 'wallet.json')
    CONFFILE = os.path.join(BASEDIR, args.config or 'config.ini')
    
    print ('Wallet path:', str(DATAFILE))
    print ('Config path:', str(CONFFILE))

Or use default value with argparse

# Allow user to specify wallet and config filenames as arguments
def handleargs():
    global DATAFILE, CONFFILE
    parser = argparse.ArgumentParser()
    parser.add_argument("-w", "--wallet", type=str, default='wallet.json' help="Specify wallet filename")
    parser.add_argument("-c", "--config", type=str, default='config.ini' help="Specify config filename")
    args = parser.parse_args()
    
    print ('Wallet path:', str(DATAFILE))
    print ('Config path:', str(CONFFILE))

@ptsand ptsand force-pushed the feature/wallet-config-args branch from 146d48b to 125e411 Compare June 7, 2018 12:13
@ptsand
Copy link
Author

ptsand commented Jun 7, 2018

Thanks rpeche. I just pushed a shorter cleaner version of the feature, which are using the globals DATAFILE and CONFFILE as default arguments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants